#ifndef CONNECTION_SOCKET_H
#define CONNECTION_SOCKET_H

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include "md5.h"
#include  <fcntl.h>
#include  <string.h>
#include  <stdlib.h>
#include <sys/stat.h>

#define INVALID_SOCKET -1

#define SIZE_DATA 256
#define SIZE_STRING 32

#define SOCKET_TEST 1
#define SOCKET_ERROR -1
#define SOCKET_FILE 4
#define SOCKET_MESSAGE 2
#define SOCKET_NAME_FILE 3
#define SOCKET_END_OF_FILE 5
#define SOCKET_CONNECT 6
#define SOCKET_LIST_FRIEND 7


typedef struct{
    int type;
    char login[SIZE_STRING];
    char pass[SIZE_STRING];
    char dest[SIZE_STRING];
    char data[SIZE_DATA];
    char checksum[SIZE_STRING];
    int size;
}requete_socket;

class connection_socket
{



public:
	char* addr_ip;
	int sockfd;
	int sock_cli;
	int port;
	bool debug_mode;
 	int taille_buffer;
 	requete_socket* requete;
 	requete_socket* reponse;
 	sockaddr_in addr;

	connection_socket();
	~connection_socket();
	bool accept_socket();
	bool connect_socket();
	bool connect_socket(char* addr_ip);
	requete_socket* recv_socket();
	bool send_socket(requete_socket* message);
	bool close_socket();
	bool close_socket_cli();
	void print(char *message);
	bool send_file(char* path, char* name_file, requete_socket* message);
	bool recv_file();
};

#endif // CONNECTION_SOCKET_H
